home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2051 < prev    next >
Encoding:
Text File  |  1996-08-05  |  686 b   |  21 lines

  1. Newsgroups: comp.lang.c
  2. Path: thinkage.on.ca!atbowler
  3. From: atbowler@thinkage.on.ca (Alan Bowler)
  4. Subject: Re: pseudo-random numbers
  5. Message-ID: <DLE110.Ixp@thinkage.on.ca>
  6. Sender: news@thinkage.on.ca
  7. Organization: Thinkage Ltd.
  8. References: <17709D420S86.JJSTEP00@ukcc.uky.edu> <4d3ijv$9fl@news.iag.net>
  9. Date: Thu, 18 Jan 1996 17:38:59 GMT
  10.  
  11. In article <4d3ijv$9fl@news.iag.net> jatmon@iag.net (John R Buchan) writes:
  12. >
  13. >One solution, suggested in the faq <polite jab>, is:
  14. >
  15. >   (int)((double)rand() / ((double)RAND_MAX + 1) * N)
  16.                                                   ^
  17.  
  18. Minor point.  You have a typo.  That should be
  19.  
  20.     (int)((double)rand() / ((double)RAND_MAX + 1) / N)
  21.